package com.huoyun.announcement.dao;

import java.util.List;

import com.huoyun.announcement.bean.Announcement;
import com.huoyun.announcement.dao.evt.QueryAnnoucemnetPageEvt;
import com.huoyun.announcement.dao.evt.GetOpenedAnnouncementPageEvt;
import com.huoyun.base.dao.BaseDaoImpl;

public class AnnouncementDaoImpl extends BaseDaoImpl<Announcement> implements AnnouncementDao {

	@Override
	public void saveAnnoucement(Announcement announcement) 
	{
		this.sqlSessionTemplate.insert("com.huoyun.announcement.dao.AnnouncementDaoMapper.saveAnnoucement", announcement);
	}

	@Override
	public void update(Announcement announcement) 
	{
		this.sqlSessionTemplate.update("com.huoyun.announcement.dao.AnnouncementDaoMapper.update", announcement);
	}

	@Override
	public List<Announcement> queryAnnoucement(String groupName) 
	{
		//return this.sqlSessionTemplate.selectList("com.huoyun.announcement.dao.AnnouncementDaoMapper.queryAnnoucement", groupName);
		return null;
	}

	@Override
	public List<Announcement> queryAll() 
	{
		return this.sqlSessionTemplate.selectList("com.huoyun.announcement.dao.AnnouncementDaoMapper.queryAll");
	}

	@Override
	public void delete(long id) 
	{
		this.sqlSessionTemplate.delete("com.huoyun.announcement.dao.AnnouncementDaoMapper.delete", id);
		
	}
	@Override
	public long queryAnnoucemnetCount(QueryAnnoucemnetPageEvt queryAnnoucemnetPageEvt)
	{
		return this.sqlSessionTemplate.selectOne("com.huoyun.announcement.dao.AnnouncementDaoMapper.queryAnnoucemnetCount", queryAnnoucemnetPageEvt);
	}
	
	
	@Override
	public List<Announcement> queryAnnoucemnetPage(QueryAnnoucemnetPageEvt queryAnnoucemnetPageEvt)
	{
		return this.sqlSessionTemplate.selectList("com.huoyun.announcement.dao.AnnouncementDaoMapper.queryAnnoucemnetPage", queryAnnoucemnetPageEvt);
	}

	@Override
	public List<Announcement> getOpenedAnnouncementPage(
			GetOpenedAnnouncementPageEvt getOpenedAnnouncementPageEvt) {
		// TODO Auto-generated method stub
		return sqlSessionTemplate.selectList("com.huoyun.announcement.dao.AnnouncementDaoMapper.getOpenedAnnouncementPage",getOpenedAnnouncementPageEvt);
	}

	@Override
	public long getOpenedAnnouncementCount(
			GetOpenedAnnouncementPageEvt getOpenedAnnouncementPageEvt) {
		// TODO Auto-generated method stub
		return sqlSessionTemplate.selectOne("com.huoyun.announcement.dao.AnnouncementDaoMapper.getOpenedAnnouncementCount",getOpenedAnnouncementPageEvt);
	}

	@Override
	public Announcement getAnnouncementById(long annId) {
		// TODO Auto-generated method stub
		return sqlSessionTemplate.selectOne("com.huoyun.announcement.dao.AnnouncementDaoMapper.getAnnouncementById",annId);
	}

}
